package com.ddn.service.hall.impl;

import com.ddn.mapper.hall.ReceptionMapper;
import com.ddn.model.hall.ReceptionVO;
import com.ddn.service.hall.ReceptionService;
import com.ddn.util.ResultData;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

/*
  ❀❀❀---扎根---❀❀❀
    ❤ @libing ❤
  
*/
@Service
public class ReceptionServiceImpl implements ReceptionService {

    @Autowired
    private ReceptionMapper receptionMapper;

    @Override
    public ResultData findAllReception(HashMap<String, Object> map) {
        String pageNo = (String) map.get("page");
        String pageSize = (String) map.get("limit");
        PageHelper.startPage(Integer.parseInt(pageNo),Integer.parseInt(pageSize));

        List<ReceptionVO> receptionVOS= receptionMapper.findAllReception(map);

        PageInfo<ReceptionVO> info =new PageInfo<>(receptionVOS);

        long l = info.getTotal();
        if (receptionVOS != null) {
            return ResultData.ok(receptionVOS,l);
        }
        return ResultData.fail();
    }

    /**
     * 删除会议厅信息
     * @param map
     * @return
     */
    @Override
    public ResultData deleteReception(HashMap<String, Object> map) {
        int i =receptionMapper.deleteReception(map);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }

    /**
     * 添加会议厅信息
     * @param map
     * @return
     */
    @Override
    public ResultData addReception(HashMap<String, Object> map) {
        int i =receptionMapper.addReception(map);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }

    /**
     * 编辑会议厅信息
     * @param map
     * @return
     */
    @Override
    public ResultData updateReception(HashMap<String, Object> map) {
        int i =receptionMapper.updateReception(map);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }

    /**
     * 批量删除会议厅信息
     * @param ids
     * @return
     */
    @Override
    public ResultData batchReception(List<Integer> ids) {
        int i =receptionMapper.batchReception(ids);
        if (i >0) {
            return ResultData.ok();
        }
        return ResultData.fail();
    }
}
